﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace PDFWriter
{
    public class PDFObjectReference : INode
    {
        private XmlDocument reader = new XmlDocument();
        public const string OBJ_REP = "ObjRef";
        
        public PDFObject GetPDFObject()
        {
            PDFObject pdfObject = new PDFObject() { Text = ProcessXML() };
            return pdfObject;
        }

        public PDFObjectReference(string xmlDictionary) {
            reader.LoadXml(xmlDictionary);
        }

        public string ProcessXML()
        {
            string resultString = null;
            if (reader.FirstChild.Name == OBJ_REP)
            {
                foreach (XmlNode node in reader.FirstChild.ChildNodes)
                {
                    resultString += " " + node.InnerText + " 0 R";
                }

            }
            
            return resultString;
        }

        #region INode Members


        public List<PDFObject> GetPDFObjects()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
